﻿using Microsoft.AspNetCore.SignalR.Client;

namespace console
{
    public class SignalrClient
    {
        private static object lockObj = new object();
        private static HubConnection connection;
        private SignalrClient() {}
        public static HubConnection Instance
        {
            get
            {
                lock (lockObj)
                {
                    if (connection == null)
                    {
                        connection = new HubConnectionBuilder()
                          .WithUrl("http://localhost:5000/instantMessage")
                          .WithAutomaticReconnect()//自动重新连接
                          .Build();
                    }
                    return connection;
                }
            }
        }
    }
}
